<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>封装一个日期函数</title>
</head>
<body>
	<script>
		var date = new Date();
		//var date = (new Date()).toLocaleString();
		console.log("date是：",date)
		function dateFormat(date,format='YYYY年MM月DD日  hh:mm:ss 周Day') {
			let config ={
				YYYY:date.getFullYear(),
				MM:date.getMonth() +1,
				DD:date.getDate(),
				hh:date.getHours(),
				mm:date.getMinutes(),
				ss:date.getSeconds(),
				Day:date.getDay()==0?7:date.getDay(),

			}
			for(let key in config){
				format = format.replace(key,config[key])
			}
			return format;
		}
		
     console.log("测试dateFormat（）方法：",dateFormat(date,'YYYY-MM-DD  hh:mm:ss 周Day'))

	</script>
	
</body>
</html>